package com.feng.common.utils;

import com.feng.security.domain.LoginUser;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @author Feng
 * @since 2022/4/19 20:25
 */
public class SecurityUtil {

    public static LoginUser getCurrentUserDetails() {
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        return (LoginUser) auth.getPrincipal();
    }

    public static int getCurrentRoleLevel() {
        return getCurrentUserDetails().getLevel();
    }
}
